home *** CD-ROM | disk | FTP | other *** search
- ;-----------------------------------------------------------------------------
- ;
- ; CPUID.ASM
- ; Version 1.1
- ;
- ; A procedure used by SYSID.PAS.
- ;
- ; CPUID returns these values in AX:
- ; AH7 : (not used, always 0)
- ; AH6 : (not used, always 0)
- ; AH5 : (not used, always 0)
- ; AH4 : (not used, always 0)
- ; AH3 : 1 if CPU mishandles interrupts of multi-prefix string
- ; instructions (Intel)
- ; AH2 : 1 if PUSH SP writes, then decrements (80286)
- ; AH1 : 1 if shift instructions ignore high 3 bits in register
- ; displacement (8018x, 80286)
- ; AH0 : 1 if prefetch instruction queue is 6 bytes (80x86)
- ; AL : 0 if no coprocessor present
- ; 1 if 8087 present
- ; 2 if 80287 present
- ;
- ; CPUID uses self-modifying code to determine the length of the prefetch
- ; instruction queue and should therefore be run only once in the course
- ; of the calling program.
- ;
- ; CPUID was shamelessly stolen from Bob Smith's article "Chips in
- ; Transition," PC Tech Journal 4:4, p. 56. It was assembled into
- ; CPUID.OBJ with MASM Version 3.0.
- ;
- ; Steve Grant
- ; Long Beach, CA
- ; July 8, 1988
- ;
- ;-----------------------------------------------------------------------------
-
- .287
- code segment byte public
- assume cs:code,ds:code
- public cpuid
- cpuid proc near
- push bp
- mov bp,sp
- xor ax,ax
- push ax
- mov cx,0FFFFH
- sti
- rep lods byte ptr es:[si]
- pop ax
- jcxz a1
- or ah,08H ; if CPU is Intel
- a1:
- push ax
- push sp
- pop ax
- cmp ax,sp
- pop ax
- jne a2
- or ah,04H ; if cpu is 8028x
- a2:
- push ax
- mov cl,21H
- mov al,0FFH
- shl al,cl
- pop ax
- jz a3
- or ah,02H ; if cpu is 8018x or 8028x
- a3:
- push ax
- mov ch,0
- push ds
- push cs
- pop ds
- cli
- jmp $+2 ; empty queue
- mov byte ptr a4,0
- db 0B1H ; MOV CL,...
- a4: db 1 ; ...1
- sti
- pop ds
- pop ax
- jcxz a5
- or ah,01H ; if PIQ length=6 (80x86)
- a5:
- cli
- fnstenv ndp_env
- sti
- fninit
- fnstcw ndp_cw
- cmp byte ptr ndp_cw+1,03h
- mov al,0
- jne a6
- and byte ptr ndp_cw,7FH
- fldcw ndp_cw
- fdisi
- fstcw ndp_cw
- fldenv ndp_env
- test byte ptr ndp_cw,80H
- mov al,1
- jnz a6
- mov al,2
- a6:
- pop bp
- ret
- ndp_env label word
- dw 7 dup (0)
- ndp_cw label word
- dw 0
- cpuid endp
- code ends
- end
-